package 售票;

public class SellTicket {
    public static void main(String[] args) {
    SK01 sk01 = new SK01();
    SK01 sk02 = new SK01();
    SK01 sk03 = new SK01();
    sk01.start();
    sk02.start();
    sk03.start();
    }
}

class SK01 extends Thread{
    private static int ticketnum=100;
    @Override
    public void run() {
        while(true){
            if(ticketnum<=0){
                System.out.println("售票结束");
                break;
            }
            try{
                Thread.sleep(50);
            }catch(InterruptedException e){
                e.printStackTrace();
            }
            System.out.println("窗口"+Thread.currentThread().getName()+"售出一张票"+"剩余票数"+(--ticketnum));
        }
    }
}
